<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Session;
use vquery;

/**
 * 统计控制器
 *
 * @author msn
 */
class Statistic extends Check {

    public function __construct() {
        parent::__construct();
        $left = controller("index");
        $left->left();
    }

    public function index() {
        $time = input("time");

        $time = base64_decode($time);
        $where2 = "";
        if ($time != "") {
            $timearr = explode("—", $time);
            $start = strtotime($timearr[0]);
            //var_dump($start);
            $end = strtotime($timearr[1]);
            //var_dump($end);
            $where2['time'] = array('between', array($start, $end));
        }
        $count = $list = db("bill")->count("money");

        $zcount = $list = db("bill")->where("income_pattern='支付宝'")->where($where2)->sum("money");
        $wcount = $list = db("bill")->where("income_pattern='微信'")->where($where2)->sum("money");
        $ycount = $list = db("bill")->where("income_pattern='银行短信'")->where($where2)->sum("money");

//        var_dump($list);
        $title = "数据统计";
        session("cue", "数据统计");
        $this->assign("title", $title);
        //---------------------------
        $this->assign("time", $time);
        $this->assign("zcount", $zcount);
        $this->assign("wcount", $wcount);
        $this->assign("ycount", $ycount);
        $this->assign("count", $count);
        return $this->fetch();
    }

}
